//const {SyncBailHook} = require('tapable');
//当回调函数返回非undefined值的时候会停止调用后续的回调
class SyncBailHook{
  constructor(args){
    this._args = args;//['name','age']
    this.taps = [];
  }
  tap(name,fn){
     this.taps.push(fn);
  }
  call(){
      let args = Array.from(arguments).slice(0,this._args.length);;
      let length = this.taps.length;
      for(let i=0;i<length;i++){
        let result = this.taps[i](...args);
        if(typeof result !== 'undefined')
          return;
      }
  }

}
let hook = new SyncBailHook(['name','age']);
//hook.on();
hook.tap('1',(name,age)=>{
  console.log(1,name,age);
});
hook.tap('2',(name,age)=>{
  console.log(2,name,age);
  return 'wrong';
});
hook.tap('3',(name,age)=>{
    console.log(3,name,age)
});
//hook.emit();hook.trigger();
hook.call('zhufeng',10);

